-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
gh-137829: Fix shelve tests for backend compatibility #137879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
I also added a new test case for wrong types from custom serializers. For example when serializers return |
Lib/test/test_shelve.py
Outdated
@@ -399,6 +411,29 @@ def deserializer(data): | |||
self.assertRaises(shelve.ShelveError, shelve.Shelf, {}, **kwargs) | |||
self.assertRaises(shelve.ShelveError, shelve.BsdDbShelf, {}, **kwargs) | |||
|
|||
def test_custom_serializer_returns_wrong_type_for_key(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test now duplicates the one when serializer returns None. As the key is never serialized, I don't think we need this one anymore.
def serializer(obj, protocol=None): | ||
pass | ||
def serializer(obj, protocol=None): | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass | |
return ["value with invalid type"] |
How about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this test case, our goal is to test the incomplete serializer. However, with the proposed change, we're defining an invalid serializer. I believe it would make more sense to use this change in a new test case, such as def test_custom_invalid_serializer(self):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but incomplete serializer just returns None which is the same as defining an invalid serializer (as the error is the same in both cases), so I'm not sure there is a notion of being "incomplete" here that we can use.
Uh oh!
There was an error while loading. Please reload this page.